var index /* 全局变量，用于存储需要编辑的问卷的索引 同时用来判断是添加页面还是编辑页面 */
var result/* 全局变量 用来存储问卷数据 */
window.onload = function () {
    index = location.search;/* 获取域名中带的数据 */
    if (!index)/* 判断是添加页面还是编辑页面 有索引时为编辑页面 */
        return  /* 编辑页面不进行以下操作 */
    index = index.slice(index.indexOf("=") + 1)/* 截取真正有用的数据 */
    result = JSON.parse(localStorage.getItem(index))/* 从本地浏览器储存中获取问卷数据 */
    document.querySelector("#Itemcontent").innerHTML = result.title/* 渲染问卷标题 */
    for (i = 1; i <= result.len; i++) { /* 循环渲染问卷中的每个问题 */
        if (result[i].type == "单选题") {/* 先对问题类型进行判断 */
            var str = ""//新增单选题模板代码
            str += '<div id="questionItem' + (result[i].num) + '" class="questionItem" onmouseover="show(' + (result[i].num) + ')" onmouseout="hide(' + (result[i].num) + ')">Q'
            str += '    <span class="none" id="type' + (result[i].num) + '">单选题</span>'
            str += '    <span class="questionNum">' + (result[i].num) + '</span> &nbsp;&nbsp;'
            str += '    <span id="ItemTitle' + (result[i].num) + '" onclick="edit(\'Title' + (result[i].num) + '\')">' + (result[i].title) + '</span>'
            str += '    <input type="text" id="Title' + (result[i].num) + '" class="none">'
            str += '    <button id="outTitle' + (result[i].num) + '" onclick="edit(\'Title' + (result[i].num) + '\')" class="none">确定</button>'
            str += '    <button id="editQue' + (result[i].num) + '" class="editQue" onclick="addradioOp(' + (result[i].num) + ')">新增选项</button>'
            str += '    <ul id="radioUl' + (result[i].num) + '">'

            for (j = 0; j < result[i].radio.len; j++) {/* 循环添加问卷问题选项 */
                str += '        <li id="radi' + (result[i].num) + (j + 1) + '" class="radios">'
                str += '            <input disabled type="radio" name="radio1" disabled>'
                str += '            <span id="ItemRad' + (result[i].num) + (j + 1) + '" class="itemCon' + (result[i].num) + '" onclick="edit(\'Rad' + (result[i].num) + (j + 1) + '\')">' + (result[i].radio[j]) + '</span>'
                str += '            <input type="text" id="Rad' + (result[i].num) + (j + 1) + '" class="none">'
                str += '            <button id="outRad' + (result[i].num) + (j + 1) + '" onclick="edit(\'Rad' + (result[i].num) + (j + 1) + '\')" class="none">确定</button>'
                str += '            <button class="dele' + (result[i].num) + ' dele none" onclick="delOp(\'radi' + (result[i].num) + (j + 1) + '\')">删除</button>'
                str += '        </li>'
            }

            str += '    </ul>'
            str += '    <div class="itemHandle" id="handle' + (result[i].num) + '">'
            if (i != 1) //第一个问题没有上移功能
                str += '        <span onclick="moveUp(' + (result[i].num) + ')">上移</span>'
            if (i != result.len)//最后一个问题没有下移功能
                str += '        <span onclick="moveDown(' + (result[i].num) + ')">下移</span>'
            str += '        <span onclick="multiplex(' + (result[i].num) + ')">复用</span>'
            str += '        <span onclick="delQus(' + (result[i].num) + ')">删除</span>'
            str += '    </div>'
            str += '</div>'
            var content = document.querySelector("#question").innerHTML/* 先获取问题标签的所有内容 */
            document.querySelector("#question").innerHTML = content + str//在所有的问题后面插入
        } else if (result[i].type == "多选题") {
            var str = ""//新增多选题模板代码
            str += '<div id="questionItem' + (result[i].num) + '" class="questionItem" onmouseover="show(' + (result[i].num) + ')" onmouseout="hide(' + (result[i].num) + ')">Q'
            str += '    <span class="none" id="type' + (result[i].num) + '">多选题</span>'
            str += '    <span class="questionNum">' + (result[i].num) + '</span> &nbsp;&nbsp;'
            str += '    <span id="ItemTitle' + (result[i].num) + '" onclick="edit(\'Title' + (result[i].num) + '\')">' + (result[i].title) + '</span>'
            str += '    <input type="text" id="Title' + (result[i].num) + '" class="none">'
            str += '    <button id="outTitle' + (result[i].num) + '" onclick="edit(\'Title' + (result[i].num) + '\')" class="none">确定</button>'
            str += '    <button id="editQue' + (result[i].num) + '" class="editQue" onclick="addcheckOp(' + (result[i].num) + ')">新增选项</button>'
            str += '    <ul id="checkUl' + (result[i].num) + '">'

            for (j = 0; j < result[i].check.len; j++) {/* 循环添加问卷问题选项 */
                str += '        <li id="chek' + (result[i].num) + (j + 1) + '" class="checks">'
                str += '            <input disabled type="checkbox" name="checkbox1">'
                str += '            <span id="ItemChe' + (result[i].num) + (j + 1) + '"  class="itemCon' + (result[i].num) + '" onclick="edit(\'Che' + (result[i].num) + (j + 1) + '\')">' + (result[i].check[j]) + '</span>'
                str += '            <input type="text" id="Che' + (result[i].num) + (j + 1) + '" class="none">'
                str += '            <button id="outChe' + (result[i].num) + (j + 1) + '" onclick="edit(\'Che' + (result[i].num) + (j + 1) + '\')" class="none">确定</button>'
                str += '            <button class="dele' + (result[i].num) + ' dele none" onclick="delOp(\'chek' + (result[i].num) + (j + 1) + '\')">删除</button>'
                str += '        </li>'
            }

            str += '    </ul>'
            str += '    <div class="itemHandle" id="handle' + (result[i].num) + '">'
            if (result[i].num != 1) //第一个问题没有上移功能
                str += '        <span onclick="moveUp(' + (result[i].num) + ')">上移</span>'
            if (result[i].num != result.len)//最后一个问题没有下移功能
                str += '        <span onclick="moveDown(' + (result[i].num) + ')">下移</span>'
            str += '        <span onclick="multiplex(' + (result[i].num) + ')">复用</span>'
            str += '        <span onclick="delQus(' + (result[i].num) + ')">删除</span>'
            str += '    </div>'
            str += '</div>'
            var content = document.querySelector("#question").innerHTML/* 先获取问题标签的所有内容 */
            document.querySelector("#question").innerHTML = content + str//在所有的问题后面插入
        } else {
            var str = ""//新增文本题模板代码
            str += '<div id="questionItem' + (result[i].num) + '" class="questionItem" onmouseover="show(' + (result[i].num) + ')" onmouseout="hide(' + (result[i].num) + ')">Q'
            str += '    <span class="none" id="type' + (result[i].num) + '">文本题</span>'
            str += '    <span class="questionNum">' + (result[i].num) + '</span> &nbsp;&nbsp;'
            str += '    <span id="ItemTitle' + (result[i].num) + '" onclick="edit(\'Title' + (result[i].num) + '\')">' + (result[i].title) + '</span>'
            str += '    <input type="text" id="Title' + (result[i].num) + '" class="none">'
            str += '    <button id="outTitle' + (result[i].num) + '" onclick="edit(\'Title' + (result[i].num) + '\')" class="none">确定</button>'
            str += '    <div style="float: right;"><input id="isMust' + (result[i].num) + '" type="checkbox"> &nbsp;&nbsp;此题是否必填</div>'
            str += '    <ul>'
            str += '        <li>'
            str += '            <input disabled class="itemCon' + (result[i].num) + '" type="text" style="width:550px" value="' + (result[i].textare) + '">'
            str += '        </li>'
            str += '    </ul>'
            str += '    <div class="itemHandle" id="handle' + (result[i].num) + '">'
            if (result[i].num != 1) //第一个问题没有上移功能
                str += '        <span onclick="moveUp(' + (result[i].num) + ')">上移</span>'
            if (result[i].num != result.len)//最后一个问题没有下移功能
                str += '        <span onclick="moveDown(' + (result[i].num) + ')">下移</span>'
            str += '        <span onclick="multiplex(' + (result[i].num) + ')">复用</span>'
            str += '        <span onclick="delQus(' + (result[i].num) + ')">删除</span>'
            str += '    </div>'
            str += '</div>'
            var content = document.querySelector("#question").innerHTML/* 先获取问题标签的所有内容 */
            document.querySelector("#question").innerHTML = content + str//在所有的问题后面插入
            var newIsId = "#isMust" + (i).toString()/* 文本框是否必填标签的id */
            document.querySelector(newIsId).checked = result[i].isMust/* 渲染文本框是否必填 */
        }
    }
    document.querySelector("#time").value = result.time/* 渲染问卷截至时间 */
}


function inspect() {//判断当前日期是否已经过去
    var D = document.querySelector("#time").value//选择的日期
    var d = new Date();//当前日期
    var nowD = d.getFullYear().toString() //当前日期的年
    if (d.getMonth() + 1 < 10)//当前日期的月 小于10时在前面添加一个0
        nowD = nowD + "-0" + (d.getMonth() + 1).toString()
    else
        nowD = nowD + "-" + (d.getMonth() + 1).toString()
    if (d.getDate() < 10)//当前日期的日 小于10时在前面添加一个0
        nowD = nowD + "-0" + d.getDate().toString()
    else
        nowD = nowD + "-0" + d.getDate().toString()
    if (D < nowD) {/* 对比日期大小 */
        alert("不能选择已经过去的时间作为截止日期")
        document.querySelector("#time").value = ""
        return
    }
}

function delOp(idName) {//删除单个问题选项
    var liId = "#" + idName//问题选项id
    document.querySelector(liId).remove();//删除问题选项
}
function addradioOp(index) {//增加单选框选项
    var length = index.toString()//单选框索引
    var radId = "#radioUl" + length//大选项标签id
    var numId = ".itemCon" + length//小选项标签class
    var len = (parseInt(document.querySelectorAll(numId).length) + 1).toString()//单选框选项数目+1 用做新选项索引
    var str = ""//问题选项模板代码
    str += '<li id="radi' + (length) + (len) + '" class="radios">'
    str += '    <input type="radio" name="radio1" disabled>'
    str += '    <span id="ItemRad' + (length) + (len) + '" class="itemCon' + (length) + '" onclick="edit(\'Rad' + (length) + (len) + '\')">选项' + (len) + '</span>'
    str += '    <input type="text" id="Rad' + (length) + (len) + '" class="none">'
    str += '    <button id="outRad' + (length) + (len) + '" onclick="edit(\'Rad' + (length) + (len) + '\')" class="none">确定</button>'
    str += '    <button class="dele' + (length) + ' dele none" onclick="delOp(\'radi' + (length) + (len) + '\')" class="none">删除</button>'
    str += '</li>'
    var content = document.querySelector(radId).innerHTML// 先获取选项标签的所有内容 
    document.querySelector(radId).innerHTML = content + str//在所有的选项后面插入
}
function addcheckOp(index) {//增加多选框选项
    var length = index.toString()//多选框索引
    var radId = "#checkUl" + length;//大选项标签id
    var numId = ".itemCon" + length//小选项标签class
    var len = (parseInt(document.querySelectorAll(numId).length) + 1).toString()//单选框选项数目+1 用做新选项索引
    var str = ""//问题选项模板代码
    str += '<li id="chek' + (length) + (len) + '">'
    str += '    <input type="checkbox" name="checkbox1" disabled>'
    str += '    <span id="ItemChe' + (length) + (len) + '" class="itemCon' + (length) + '" onclick="edit(\'Che' + (length) + (len) + '\')">选项' + (len) + '</span>'
    str += '    <input type="text" id="Che' + (length) + (len) + '" class="none">'
    str += '    <button id="outChe' + (length) + (len) + '" onclick="edit(\'Che' + (length) + (len) + '\')" class="none">确定</button>'
    str += '    <button class="dele' + (length) + ' dele none" onclick="delOp(\'Che' + (length) + (len) + '\')" class="none">删除</button>'
    str += '</li>'
    var content = document.querySelector(radId).innerHTML// 先获取选项标签的所有内容 
    document.querySelector(radId).innerHTML = content + str//在所有的选项后面插入
}

function edit(idName) {//点击编辑问题
    var spanId = "#Item" + idName//非编辑模式时的内容的id
    var inputId = "#" + idName//编辑模式时的input框的id
    var btnId = "#out" + idName//编辑模式时的按钮的id
    var span = document.querySelector(spanId)//获取对应标签
    var input = document.querySelector(inputId)//获取对应标签
    if (span.style.display == "none") {//未编辑
        span.innerHTML = input.value
        input.style.display = "none"//隐藏
        var input = document.querySelector(btnId).style.display = "none"//隐藏
        span.style.display = "inline-block";//显示
    } else {//编辑
        input.value = span.innerHTML
        span.style.display = "none"//隐藏
        input.style.display = "inline-block";//显示
        var input = document.querySelector(btnId).style.display = "inline-block"//显示
    }
}
function show(index) {//鼠标进入时显示可对当前问题进行的操作
    var handleId = "#handle" + index.toString()//操作标签的id
    var editId = "#editQue" + index.toString()//新增选项的按钮的id
    var delID = ".dele" + index.toString()//删除选项的按钮的class
    document.querySelector(handleId).style.display = "block"//显示
    if (document.querySelector(editId)) {
        document.querySelector(editId).style.display = "block"//显示
        var dels = document.querySelectorAll(delID)
        for (i = 0; i < dels.length; i++) {
            dels[i].style.display = "inline-block"//显示
        }
    }

}
function hide(index) {//鼠标退出时隐藏可对当前问题进行的操作
    var handleId = "#handle" + index.toString()
    var editId = "#editQue" + index.toString()
    var delID = ".dele" + index.toString()
    document.querySelector(handleId).style.display = "none"
    if (document.querySelector(editId)) {
        document.querySelector(editId).style.display = "none"
        var dels = document.querySelectorAll(delID)
        for (i = 0; i < dels.length; i++) {
            dels[i].style.display = "none"
        }
    }
}
function addque() {//点击添加问题显示单选题、多选题和文本题
    var length = parseInt(document.querySelectorAll(".questionNum").length)
    if (length >= 10) {
        alert("问题数目不能超过十个")
        return
    } else
        document.querySelector("#addCheck").style.display = "block"
}

function radioQue() {//新增单选题
    var length = (parseInt(document.querySelectorAll(".questionNum").length) + 1).toString()//问题数量+1 用做新问题的索引
    var str = ""//新增单选题模板代码
    str += '<div id="questionItem' + (length) + '" class="questionItem" onmouseover="show(' + (length) + ')" onmouseout="hide(' + (length) + ')">Q'
    str += '    <span class="none" id="type' + (length) + '">单选题</span>'
    str += '    <span class="questionNum">' + (length) + '</span> &nbsp;&nbsp;'
    str += '    <span id="ItemTitle' + (length) + '" onclick="edit(\'Title' + (length) + '\')">单选题</span>'
    str += '    <input type="text" id="Title' + (length) + '" class="none">'
    str += '    <button id="outTitle' + (length) + '" onclick="edit(\'Title' + (length) + '\')" class="none">确定</button>'
    str += '    <button id="editQue' + (length) + '" class="editQue" onclick="addradioOp(' + (length) + ')">新增选项</button>'
    str += '    <ul id="radioUl' + (length) + '">'
    str += '        <li id="radi' + (length) + '1" class="radios">'
    str += '            <input disabled type="radio" name="radio1" disabled>'
    str += '            <span id="ItemRad' + (length) + '1" class="itemCon' + (length) + '" onclick="edit(\'Rad' + (length) + '1\')">选项1</span>'
    str += '            <input type="text" id="Rad' + (length) + '1" class="none">'
    str += '            <button id="outRad' + (length) + '1" onclick="edit(\'Rad' + (length) + '1\')" class="none">确定</button>'
    str += '            <button class="dele' + (length) + ' dele none" onclick="delOp(\'radi' + (length) + '1\')">删除</button>'
    str += '        </li>'
    str += '        <li id="radi' + (length) + '2" class="radios">'
    str += '            <input disabled type="radio" name="radio1" disabled>'
    str += '            <span id="ItemRad' + (length) + '2" class="itemCon' + (length) + '" onclick="edit(\'Rad' + (length) + '2\')">选项2</span>'
    str += '            <input type="text" id="Rad' + (length) + '2" class="none">'
    str += '            <button id="outRad' + (length) + '2" onclick="edit(\'Rad' + (length) + '2\')" class="none">确定</button>'
    str += '            <button class="dele' + (length) + ' dele none" onclick="delOp(\'radi' + (length) + '2\')">删除</button>'
    str += '        </li>'
    str += '    </ul>'
    str += '    <div class="itemHandle" id="handle' + (length) + '">'
    if (length != '1') {//第一个问题没有上移功能
        str += '        <span onclick="moveUp(' + (length) + ')">上移</span>'
    }
    str += '        <span onclick="multiplex(' + (length) + ')">复用</span>'
    str += '        <span onclick="delQus(' + (length) + ')">删除</span>'
    str += '    </div>'
    str += '</div>'
    var content = document.querySelector("#question").innerHTML/* 先获取问题标签的所有内容 */
    var len = document.querySelectorAll(".questionNum").length//未新增前的问题总数 
    document.querySelector("#question").innerHTML = content + str//在所有的问题后面插入
    if (document.querySelectorAll(".questionNum").length > 1) {//未新增前有问题时进行
        var handleId = "#handle" + len
        var newHand = ""
        if (len != '1') {//第一个问题没有上移功能
            newHand += '        <span onclick="moveUp(' + (len) + ')">上移</span>'
        }
        newHand += '        <span onclick="moveDown(' + (len) + ')">下移</span>'//给倒数第二个问题加上下移功能
        newHand += '        <span onclick="multiplex(' + (len) + ')">复用</span>'
        newHand += '        <span onclick="delQus(' + (len) + ')">删除</span>'
        document.querySelector(handleId).innerHTML = newHand//用于改边原来的最后一个问题的操作内容和个数
    }
    document.querySelector("#addCheck").style.display = "none"//添加完成后隐藏添加问题中的三个选择按钮
}
function cheQue() {
    var length = (parseInt(document.querySelectorAll(".questionNum").length) + 1).toString()//问题数量+1 用做新问题的索引
    var str = ""//新增多选题模板代码
    str += '<div id="questionItem' + (length) + '" class="questionItem" onmouseover="show(' + (length) + ')" onmouseout="hide(' + (length) + ')">Q'
    str += '    <span class="none" id="type' + (length) + '">多选题</span>'
    str += '    <span class="questionNum">' + (length) + '</span> &nbsp;&nbsp;'
    str += '    <span id="ItemTitle' + (length) + '" onclick="edit(\'Title' + (length) + '\')">多选题</span>'
    str += '    <input type="text" id="Title' + (length) + '" class="none">'
    str += '    <button id="outTitle' + (length) + '" onclick="edit(\'Title' + (length) + '\')" class="none">确定</button>'
    str += '    <button id="editQue' + (length) + '" class="editQue" onclick="addcheckOp(' + (length) + ')">新增选项</button>'
    str += '    <ul id="checkUl' + (length) + '">'
    str += '        <li id="chek' + (length) + '1" class="checks">'
    str += '            <input disabled type="checkbox" name="checkbox1">'
    str += '            <span id="ItemChe' + (length) + '1"  class="itemCon' + (length) + '" onclick="edit(\'Che' + (length) + '1\')">选项1</span>'
    str += '            <input type="text" id="Che' + (length) + '1" class="none">'
    str += '            <button id="outChe' + (length) + '1" onclick="edit(\'Che' + (length) + '1\')" class="none">确定</button>'
    str += '            <button class="dele' + (length) + ' dele none" onclick="delOp(\'chek' + (length) + '1\')">删除</button>'
    str += '        </li>'
    str += '        <li id="chek' + (length) + '2" class="checks">'
    str += '            <input disabled type="checkbox" name="checkbox1">'
    str += '            <span id="ItemChe' + (length) + '2"  class="itemCon' + (length) + '" onclick="edit(\'Che' + (length) + '2\')">选项2</span>'
    str += '            <input type="text" id="Che' + (length) + '2" class="none">'
    str += '            <button id="outChe' + (length) + '2" onclick="edit(\'Che' + (length) + '2\')" class="none">确定</button>'
    str += '            <button class="dele' + (length) + ' dele none" onclick="delOp(\'chek' + (length) + '2\')">删除</button>'
    str += '        </li>'
    str += '        <li id="chek' + (length) + '3" class="checks">'
    str += '            <input disabled type="checkbox" name="checkbox1">'
    str += '            <span id="ItemChe' + (length) + '3"  class="itemCon' + (length) + '" onclick="edit(\'Che' + (length) + '3\')">选项3</span>'
    str += '            <input type="text" id="Che' + (length) + '3" class="none">'
    str += '            <button id="outChe' + (length) + '3" onclick="edit(\'Che' + (length) + '3\')" class="none">确定</button>'
    str += '            <button class="dele' + (length) + ' dele none" onclick="delOp(\'chek' + (length) + '3\')">删除</button>'
    str += '        </li>'
    str += '        <li id="chek' + (length) + '4" class="checks">'
    str += '            <input disabled type="checkbox" name="checkbox1">'
    str += '            <span id="ItemChe' + (length) + '4"  class="itemCon' + (length) + '" onclick="edit(\'Che' + (length) + '4\')">选项4</span>'
    str += '            <input type="text" id="Che' + (length) + '4" class="none">'
    str += '            <button id="outChe' + (length) + '4" onclick="edit(\'Che' + (length) + '4\')" class="none">确定</button>'
    str += '            <button class="dele' + (length) + ' dele none" onclick="delOp(\'chek' + (length) + '4\')">删除</button>'
    str += '        </li>'
    str += '    </ul>'
    str += '    <div class="itemHandle" id="handle' + (length) + '">'
    if (length > '1') {//第一个问题没有上移功能
        str += '        <span onclick="moveUp(' + (length) + ')">上移</span>'
    }
    str += '        <span onclick="multiplex(' + (length) + ')">复用</span>'
    str += '        <span onclick="delQus(' + (length) + ')">删除</span>'
    str += '    </div>'
    str += '</div>'
    var content = document.querySelector("#question").innerHTML/* 先获取问题标签的所有内容 */
    var len = document.querySelectorAll(".questionNum").length//未新增前的问题总数 
    document.querySelector("#question").innerHTML = content + str//在所有的问题后面插入
    if (document.querySelectorAll(".questionNum").length > 1) {//未新增前有问题时进行
        var handleId = "#handle" + len
        var newHand = ""
        if (len != '1') {//第一个问题没有上移功能
            newHand += '        <span onclick="moveUp(' + (len) + ')">上移</span>'
        }
        newHand += '        <span onclick="moveDown(' + (len) + ')">下移</span>'//给倒数第二个问题加上下移功能
        newHand += '        <span onclick="multiplex(' + (len) + ')">复用</span>'
        newHand += '        <span onclick="delQus(' + (len) + ')">删除</span>'
        document.querySelector(handleId).innerHTML = newHand//用于改边原来的最后一个问题的操作内容和个数
    }
    document.querySelector("#addCheck").style.display = "none"//添加完成后隐藏添加问题中的三个选择按钮
}
function textQue() {
    var length = (parseInt(document.querySelectorAll(".questionNum").length) + 1).toString()//问题数量+1 用做新问题的索引
    var str = ""//新增文本题模板代码
    str += '<div id="questionItem' + (length) + '" class="questionItem" onmouseover="show(' + (length) + ')" onmouseout="hide(' + (length) + ')">Q'
    str += '    <span class="none" id="type' + (length) + '">文本题</span>'
    str += '    <span class="questionNum">' + (length) + '</span> &nbsp;&nbsp;'
    str += '    <span id="ItemTitle' + (length) + '" onclick="edit(\'Title' + (length) + '\')">文本题</span>'
    str += '    <input type="text" id="Title' + (length) + '" class="none">'
    str += '    <button id="outTitle' + (length) + '" onclick="edit(\'Title' + (length) + '\')" class="none">确定</button>'
    str += '    <div style="float: right;"><input id="isMust' + (length) + '" type="checkbox"> &nbsp;&nbsp;此题是否必填</div>'
    str += '    <ul>'
    str += '        <li>'
    str += '            <input disabled class="itemCon' + (length) + '" type="text" style="width:550px">'
    str += '        </li>'
    str += '    </ul>'
    str += '    <div class="itemHandle" id="handle' + (length) + '">'
    if (length != '1') {//第一个问题没有上移功能
        str += '        <span onclick="moveUp(' + (length) + ')">上移</span>'
    }
    str += '        <span onclick="multiplex(' + (length) + ')">复用</span>'
    str += '        <span onclick="delQus(' + (length) + ')">删除</span>'
    str += '    </div>'
    str += '</div>'
    var content = document.querySelector("#question").innerHTML/* 先获取问题标签的所有内容 */
    var len = document.querySelectorAll(".questionNum").length//未新增前的问题总数 
    document.querySelector("#question").innerHTML = content + str//在所有的问题后面插入
    if (document.querySelectorAll(".questionNum").length > 1) {//未新增前有问题时进行
        var handleId = "#handle" + len
        var newHand = ""
        if (len != '1') {//第一个问题没有上移功能
            newHand += '        <span onclick="moveUp(' + (len) + ')">上移</span>'
        }
        newHand += '        <span onclick="moveDown(' + (len) + ')">下移</span>'//给倒数第二个问题加上下移功能
        newHand += '        <span onclick="multiplex(' + (len) + ')">复用</span>'
        newHand += '        <span onclick="delQus(' + (len) + ')">删除</span>'
        document.querySelector(handleId).innerHTML = newHand//用于改边原来的最后一个问题的操作内容和个数
    }
    document.querySelector("#addCheck").style.display = "none"//添加完成后隐藏添加问题中的三个选择按钮
}


function moveUp(index) {//上移
    var length = parseInt(document.querySelectorAll(".questionNum").length)//获取问题个数
    var id = "#questionItem" + (index).toString()
    var typeId = "#type" + (index - 1).toString()
    var type = document.querySelector(typeId).innerHTML //问题类型
    var titId = "#ItemTitle" + (index - 1).toString()
    var title = document.querySelector(titId).innerHTML //问题标题
    if (type == "单选题") {//不同的问题对应不同的代码
        var radioClass = ".itemCon" + (index - 1).toString()
        var radios = document.querySelectorAll(radioClass) //先储存选项内容
    } else if (type == "多选题") {
        var checkClass = ".itemCon" + (index - 1).toString()
        var checks = document.querySelectorAll(checkClass)//先储存选项内容
    } else {
        var textClass = ".itemCon" + (index - 1).toString()
        var isId = "#isMust" + (index - 1).toString()
        var texts = document.querySelector(textClass).value//先储存选项内容
        var isMust = document.querySelector(isId).checked//储存文本题是否必填
    }


    var id1 = "#questionItem" + (index - 1).toString()
    var typeId1 = "#type" + (index).toString()
    var type1 = document.querySelector(typeId1).innerHTML //问题类型
    var titId1 = "#ItemTitle" + (index).toString()
    var title1 = document.querySelector(titId1).innerHTML//问题标题
    if (type1 == "单选题") {//不同的问题对应不同的代码
        var radioClass1 = ".itemCon" + (index).toString()
        var radios1 = document.querySelectorAll(radioClass1) //选项内容

        var str = ""//渲染到新模板
        str += '    Q<span class="none" id="type' + (index - 1) + '">单选题</span>'
        str += '    <span class="questionNum">' + (index - 1) + '</span> &nbsp;&nbsp;'
        str += '    <span id="ItemTitle' + (index - 1) + '" onclick="edit(\'Title' + (index - 1) + '\')">' + (title1) + '</span>'
        str += '    <input type="text" id="Title' + (index - 1) + '" class="none">'
        str += '    <button id="outTitle' + (index - 1) + '" onclick="edit(\'Title' + (index - 1) + '\')" class="none">确定</button>'
        str += '    <button id="editQue' + (index - 1) + '" class="editQue" onclick="addradioOp(' + (index - 1) + ')">新增选项</button>'
        str += '    <ul id="radioUl' + (index - 1) + '">'
        for (j = 0; j < radios1.length; j++) {
            str += '        <li id="radi' + (index - 1) + (j + 1) + '" class="radios">'
            str += '            <input disabled type="radio" name="radio1" disabled>'
            str += '            <span id="ItemRad' + (index - 1) + (j + 1) + '" class="itemCon' + (index - 1) + '" onclick="edit(\'Rad' + (index - 1) + (j + 1) + '\')">' + (radios1[j].innerHTML) + '</span>'
            str += '            <input type="text" id="Rad' + (index - 1) + (j + 1) + '" class="none">'
            str += '            <button id="outRad' + (index - 1) + (j + 1) + '" onclick="edit(\'Rad' + (index - 1) + (j + 1) + '\')" class="none">确定</button>'
            str += '            <button class="dele' + (index - 1) + ' dele none" onclick="delOp(\'radi' + (index - 1) + (j + 1) + '\')">删除</button>'
            str += '        </li>'
        }
        str += '    </ul>'
        str += '    <div class="itemHandle" id="handle' + (index - 1) + '">'
        if (index - 1 != 1)//第一个问题没有上移功能
            str += '        <span onclick="moveUp(' + (index - 1) + ')">上移</span>'
        str += '        <span onclick="moveDown(' + (index - 1) + ')">下移</span>'
        str += '        <span onclick="multiplex(' + (index - 1) + ')">复用</span>'
        str += '        <span onclick="delQus(' + (index - 1) + ')">删除</span>'
        str += '    </div>'
        var radioQue = document.querySelector(id1)//需要上移的问题的上一个问题的标签
        radioQue.innerHTML = str//再渲染到页面
    } else if (type1 == "多选题") {
        var checkClass1 = ".itemCon" + (index).toString()
        var checks1 = document.querySelectorAll(checkClass1)//选项内容
        var str = ""//渲染到新模板
        str += '    Q<span class="none" id="type' + (index - 1) + '">多选题</span>'
        str += '    <span class="questionNum">' + (index - 1) + '</span> &nbsp;&nbsp;'
        str += '    <span id="ItemTitle' + (index - 1) + '" onclick="edit(\'Title' + (index - 1) + '\')">' + (title1) + '</span>'
        str += '    <input type="text" id="Title' + (index - 1) + '" class="none">'
        str += '    <button id="outTitle' + (index - 1) + '" onclick="edit(\'Title' + (index - 1) + '\')" class="none">确定</button>'
        str += '    <button id="editQue' + (index - 1) + '" class="editQue" onclick="addcheckOp(' + (index - 1) + ')">新增选项</button>'
        str += '    <ul id="checkUl' + (index - 1) + '">'
        for (j = 0; j < checks1.length; j++) {
            str += '        <li id="chek' + (index - 1) + (j + 1) + '" class="checks">'
            str += '            <input disabled type="checkbox" name="checkbox1">'
            str += '            <span id="ItemChe' + (index - 1) + (j + 1) + '"  class="itemCon' + (index - 1) + '" onclick="edit(\'Che' + (index - 1) + (j + 1) + '\')">' + (checks1[j].innerHTML) + '</span>'
            str += '            <input type="text" id="Che' + (index - 1) + (j + 1) + '" class="none">'
            str += '            <button id="outChe' + (index - 1) + (j + 1) + '" onclick="edit(\'Che' + (index - 1) + (j + 1) + '\')" class="none">确定</button>'
            str += '            <button class="dele' + (index - 1) + ' dele none" onclick="delOp(\'chek' + (index - 1) + (j + 1) + '\')">删除</button>'
            str += '        </li>'
        }
        str += '    </ul>'
        str += '    <div class="itemHandle" id="handle' + (index - 1) + '">'
        if (index - 1 != 1)//第一个问题没有上移功能
            str += '        <span onclick="moveUp(' + (index - 1) + ')">上移</span>'
        str += '        <span onclick="moveDown(' + (index - 1) + ')">下移</span>'
        str += '        <span onclick="multiplex(' + (index - 1) + ')">复用</span>'
        str += '        <span onclick="delQus(' + (index - 1) + ')">删除</span>'
        str += '    </div>'
        var checkQue = document.querySelector(id1)//需要上移的问题的上一个问题的标签
        checkQue.innerHTML = str//再渲染到页面
    } else {
        var textClass1 = ".itemCon" + (index).toString()
        var isId1 = "#isMust" + (index).toString()
        var texts1 = document.querySelector(textClass1).value//先储存选项内容
        var isMust1 = document.querySelector(isId1).checked
        var str = ""//渲染到新模板
        str += '    Q<span class="none" id="type' + (index - 1) + '">文本题</span>'
        str += '    <span class="questionNum">' + (index - 1) + '</span> &nbsp;&nbsp;'
        str += '    <span id="ItemTitle' + (index - 1) + '" onclick="edit(\'Title' + (index - 1) + '\')">' + (title1) + '</span>'
        str += '    <input type="text" id="Title' + (index - 1) + '" class="none">'
        str += '    <button id="outTitle' + (index - 1) + '" onclick="edit(\'Title' + (index - 1) + '\')" class="none">确定</button>'
        str += '    <div style="float: right;"><input id="isMust' + (index - 1) + '" type="checkbox"> &nbsp;&nbsp;此题是否必填</div>'
        str += '    <ul>'
        str += '        <li>'
        str += '            <input disabled class="itemCon' + (index - 1) + '" type="text" style="width:550px" value="' + (texts1) + '">'
        str += '        </li>'
        str += '    </ul>'
        str += '    <div class="itemHandle" id="handle' + (index - 1) + '">'
        if (index - 1 != 1)//第一个问题没有上移功能
            str += '        <span onclick="moveUp(' + (index - 1) + ')">上移</span>'
        str += '        <span onclick="moveDown(' + (index - 1) + ')">下移</span>'
        str += '        <span onclick="multiplex(' + (index - 1) + ')">复用</span>'
        str += '        <span onclick="delQus(' + (index - 1) + ')">删除</span>'
        str += '    </div>'
        var textQue = document.querySelector(id1)//需要上移的问题的上一个问题的标签
        textQue.innerHTML = str//再渲染到页面
        var newIsId = "#isMust" + (index - 1).toString()//是否必填渲染
        document.querySelector(newIsId).checked = isMust1
    }

    if (type == "单选题") {//不同的问题对应不同的代码
        var str = ""//渲染到新模板
        str += '    Q<span class="none" id="type' + (index) + '">单选题</span>'
        str += '    <span class="questionNum">' + (index) + '</span> &nbsp;&nbsp;'
        str += '    <span id="ItemTitle' + (index) + '" onclick="edit(\'Title' + (index) + '\')">' + (title) + '</span>'
        str += '    <input type="text" id="Title' + (index) + '" class="none">'
        str += '    <button id="outTitle' + (index) + '" onclick="edit(\'Title' + (index) + '\')" class="none">确定</button>'
        str += '    <button id="editQue' + (index) + '" class="editQue" onclick="addradioOp(' + (index) + ')">新增选项</button>'
        str += '    <ul id="radioUl' + (index) + '">'
        for (j = 0; j < radios.length; j++) {
            str += '        <li id="radi' + (index) + (j + 1) + '" class="radios">'
            str += '            <input disabled type="radio" name="radio1" disabled>'
            str += '            <span id="ItemRad' + (index) + (j + 1) + '" class="itemCon' + (index) + '" onclick="edit(\'Rad' + (index) + (j + 1) + '\')">' + (radios[j].innerHTML) + '</span>'
            str += '            <input type="text" id="Rad' + (index) + (j + 1) + '" class="none">'
            str += '            <button id="outRad' + (index) + (j + 1) + '" onclick="edit(\'Rad' + (index) + (j + 1) + '\')" class="none">确定</button>'
            str += '            <button class="dele' + (index) + ' dele none" onclick="delOp(\'radi' + (index) + (j + 1) + '\')">删除</button>'
            str += '        </li>'
        }
        str += '    </ul>'
        str += '    <div class="itemHandle" id="handle' + (index) + '">'
        str += '        <span onclick="moveUp(' + (index) + ')">上移</span>'
        if (index != length)//最后一个问题没有下移功能
            str += '        <span onclick="moveDown(' + (index) + ')">下移</span>'
        str += '        <span onclick="multiplex(' + (index) + ')">复用</span>'
        str += '        <span onclick="delQus(' + (index) + ')">删除</span>'
        str += '    </div>'
        var radioQue = document.querySelector(id)//需要上移的问题的的标签
        radioQue.innerHTML = str//再渲染到页面
    } else if (type == "多选题") {
        var str = ""//渲染到新模板
        str += '    Q<span class="none" id="type' + (index) + '">多选题</span>'
        str += '    <span class="questionNum">' + (index) + '</span> &nbsp;&nbsp;'
        str += '    <span id="ItemTitle' + (index) + '" onclick="edit(\'Title' + (index) + '\')">' + (title) + '</span>'
        str += '    <input type="text" id="Title' + (index) + '" class="none">'
        str += '    <button id="outTitle' + (index) + '" onclick="edit(\'Title' + (index) + '\')" class="none">确定</button>'
        str += '    <button id="editQue' + (index) + '" class="editQue" onclick="addcheckOp(' + (index) + ')">新增选项</button>'
        str += '    <ul id="checkUl' + (index) + '">'
        for (j = 0; j < checks.length; j++) {
            str += '        <li id="chek' + (index) + (j + 1) + '" class="checks">'
            str += '            <input disabled type="checkbox" name="checkbox1">'
            str += '            <span id="ItemChe' + (index) + (j + 1) + '"  class="itemCon' + (index) + '" onclick="edit(\'Che' + (index) + (j + 1) + '\')">' + (checks[j].innerHTML) + '</span>'
            str += '            <input type="text" id="Che' + (index) + (j + 1) + '" class="none">'
            str += '            <button id="outChe' + (index) + (j + 1) + '" onclick="edit(\'Che' + (index) + (j + 1) + '\')" class="none">确定</button>'
            str += '            <button class="dele' + (index) + ' dele none" onclick="delOp(\'chek' + (index) + (j + 1) + '\')">删除</button>'
            str += '        </li>'
        }
        str += '    </ul>'
        str += '    <div class="itemHandle" id="handle' + (index) + '">'
        str += '        <span onclick="moveUp(' + (index) + ')">上移</span>'
        if (index != length)//最后一个问题没有下移功能
            str += '        <span onclick="moveDown(' + (index) + ')">下移</span>'
        str += '        <span onclick="multiplex(' + (index) + ')">复用</span>'
        str += '        <span onclick="delQus(' + (index) + ')">删除</span>'
        str += '    </div>'
        var checkQue = document.querySelector(id)//需要上移的问题的的标签
        checkQue.innerHTML = str//再渲染到页面
    } else {
        var str = ""//渲染到新模板
        str += '    Q<span class="none" id="type' + (index) + '">文本题</span>'
        str += '    <span class="questionNum">' + (index) + '</span> &nbsp;&nbsp;'
        str += '    <span id="ItemTitle' + (index) + '" onclick="edit(\'Title' + (index) + '\')">' + (title) + '</span>'
        str += '    <div style="float: right;"><input id="isMust' + (index) + '" type="checkbox"> &nbsp;&nbsp;此题是否必填</div>'
        str += '    <ul>'
        str += '        <li>'
        str += '            <input disabled class="itemCon' + (index) + '" type="text" style="width:550px" value="' + (texts) + '">'
        str += '        </li>'
        str += '    </ul>'
        str += '    <div class="itemHandle" id="handle' + (index) + '">'
        str += '        <span onclick="moveUp(' + (index) + ')">上移</span>'
        if (index != length)//最后一个问题没有下移功能
            str += '        <span onclick="moveDown(' + (index) + ')">下移</span>'
        str += '        <span onclick="multiplex(' + (index) + ')">复用</span>'
        str += '        <span onclick="delQus(' + (index) + ')">删除</span>'
        str += '    </div>'
        var textQue = document.querySelector(id)//需要上移的问题的的标签
        textQue.innerHTML = str//再渲染到页面
        var newIsId = "#isMust" + (index).toString()
        document.querySelector(newIsId).checked = isMust//是否必填渲染
    }
}
function moveDown(index) {//下移
    var length = parseInt(document.querySelectorAll(".questionNum").length)//获取问题个数
    var id = "#questionItem" + (index).toString()
    var typeId = "#type" + (index + 1).toString()
    var type = document.querySelector(typeId).innerHTML //问题类型
    var titId = "#ItemTitle" + (index + 1).toString()
    var title = document.querySelector(titId).innerHTML //问题标题
    if (type == "单选题") {//不同的问题对应不同的代码
        var radioClass = ".itemCon" + (index + 1).toString()
        var radios = document.querySelectorAll(radioClass) //先储存选项内容
    } else if (type == "多选题") {
        var checkClass = ".itemCon" + (index + 1).toString()
        var checks = document.querySelectorAll(checkClass)//先储存选项内容
    } else {
        var textClass = ".itemCon" + (index + 1).toString()
        var isId = "#isMust" + (index + 1).toString()
        var texts = document.querySelector(textClass).value//先储存选项内容
        var isMust = document.querySelector(isId).checked
    }


    var id1 = "#questionItem" + (index + 1).toString()
    var typeId1 = "#type" + (index).toString()
    var type1 = document.querySelector(typeId1).innerHTML //问题类型
    var titId1 = "#ItemTitle" + (index).toString()
    var title1 = document.querySelector(titId1).innerHTML //问题标题
    if (type1 == "单选题") {//不同的问题对应不同的代码
        var radioClass1 = ".itemCon" + (index).toString()
        var radios1 = document.querySelectorAll(radioClass1) //选项内容

        var str = ""//渲染到新模板
        str += '    Q<span class="none" id="type' + (index + 1) + '">单选题</span>'
        str += '    <span class="questionNum">' + (index + 1) + '</span> &nbsp;&nbsp;'
        str += '    <span id="ItemTitle' + (index + 1) + '" onclick="edit(\'Title' + (index + 1) + '\')">' + (title1) + '</span>'
        str += '    <input type="text" id="Title' + (index + 1) + '" class="none">'
        str += '    <button id="outTitle' + (index + 1) + '" onclick="edit(\'Title' + (index + 1) + '\')" class="none">确定</button>'
        str += '    <button id="editQue' + (index + 1) + '" class="editQue" onclick="addradioOp(' + (index + 1) + ')">新增选项</button>'
        str += '    <ul id="radioUl' + (index + 1) + '">'
        for (j = 0; j < radios1.length; j++) {
            str += '        <li id="radi' + (index + 1) + (j + 1) + '" class="radios">'
            str += '            <input disabled type="radio" name="radio1" disabled>'
            str += '            <span id="ItemRad' + (index + 1) + (j + 1) + '" class="itemCon' + (index + 1) + '" onclick="edit(\'Rad' + (index + 1) + (j + 1) + '\')">' + (radios1[j].innerHTML) + '</span>'
            str += '            <input type="text" id="Rad' + (index + 1) + (j + 1) + '" class="none">'
            str += '            <button id="outRad' + (index + 1) + (j + 1) + '" onclick="edit(\'Rad' + (index + 1) + (j + 1) + '\')" class="none">确定</button>'
            str += '            <button class="dele' + (index + 1) + ' dele none" onclick="delOp(\'radi' + (index + 1) + (j + 1) + '\')">删除</button>'
            str += '        </li>'
        }
        str += '    </ul>'
        str += '    <div class="itemHandle" id="handle' + (index + 1) + '">'
        str += '        <span onclick="moveUp(' + (index + 1) + ')">上移</span>'
        if (index + 1 != length)//最后一个问题没有下移功能
            str += '        <span onclick="moveDown(' + (index + 1) + ')">下移</span>'
        str += '        <span onclick="multiplex(' + (index + 1) + ')">复用</span>'
        str += '        <span onclick="delQus(' + (index + 1) + ')">删除</span>'
        str += '    </div>'
        var radioQue = document.querySelector(id1)//需要下移的问题的下一个的标签
        radioQue.innerHTML = str//再渲染到页面
    } else if (type1 == "多选题") {
        var checkClass1 = ".itemCon" + (index).toString()
        var checks1 = document.querySelectorAll(checkClass1)//选项内容
        var str = ""//渲染到新模板
        str += '    Q<span class="none" id="type' + (index + 1) + '">多选题</span>'
        str += '    <span class="questionNum">' + (index + 1) + '</span> &nbsp;&nbsp;'
        str += '    <span id="ItemTitle' + (index + 1) + '" onclick="edit(\'Title' + (index + 1) + '\')">' + (title1) + '</span>'
        str += '    <input type="text" id="Title' + (index + 1) + '" class="none">'
        str += '    <button id="outTitle' + (index + 1) + '" onclick="edit(\'Title' + (index + 1) + '\')" class="none">确定</button>'
        str += '    <button id="editQue' + (index + 1) + '" class="editQue" onclick="addcheckOp(' + (index + 1) + ')">新增选项</button>'
        str += '    <ul id="checkUl' + (index + 1) + '">'
        for (j = 0; j < checks1.length; j++) {
            str += '        <li id="chek' + (index + 1) + (j + 1) + '" class="checks">'
            str += '            <input disabled type="checkbox" name="checkbox1">'
            str += '            <span id="ItemChe' + (index + 1) + (j + 1) + '"  class="itemCon' + (index + 1) + '" onclick="edit(\'Che' + (index + 1) + (j + 1) + '\')">' + (checks1[j].innerHTML) + '</span>'
            str += '            <input type="text" id="Che' + (index + 1) + (j + 1) + '" class="none">'
            str += '            <button id="outChe' + (index + 1) + (j + 1) + '" onclick="edit(\'Che' + (index + 1) + (j + 1) + '\')" class="none">确定</button>'
            str += '            <button class="dele' + (index + 1) + ' dele none" onclick="delOp(\'chek' + (index + 1) + (j + 1) + '\')">删除</button>'
            str += '        </li>'
        }
        str += '    </ul>'
        str += '    <div class="itemHandle" id="handle' + (index + 1) + '">'
        str += '        <span onclick="moveUp(' + (index + 1) + ')">上移</span>'
        if (index + 1 != length)//最后一个问题没有下移功能
            str += '        <span onclick="moveDown(' + (index + 1) + ')">下移</span>'
        str += '        <span onclick="multiplex(' + (index + 1) + ')">复用</span>'
        str += '        <span onclick="delQus(' + (index + 1) + ')">删除</span>'
        str += '    </div>'
        var checkQue = document.querySelector(id1)//需要下移的问题的下一个的标签
        checkQue.innerHTML = str//再渲染到页面
    } else {
        var textClass1 = ".itemCon" + (index).toString()
        var isId1 = "#isMust" + (index).toString()
        var texts1 = document.querySelector(textClass1).value//先储存选项内容
        var isMust1 = document.querySelector(isId1).checked
        var str = ""//渲染到新模板
        str += '    Q<span class="none" id="type' + (index + 1) + '">文本题</span>'
        str += '    <span class="questionNum">' + (index + 1) + '</span> &nbsp;&nbsp;'
        str += '    <span id="ItemTitle' + (index + 1) + '" onclick="edit(\'Title' + (index + 1) + '\')">' + (title1) + '</span>'
        str += '    <input type="text" id="Title' + (index + 1) + '" class="none">'
        str += '    <button id="outTitle' + (index + 1) + '" onclick="edit(\'Title' + (index + 1) + '\')" class="none">确定</button>'
        str += '    <div style="float: right;"><input id="isMust' + (index + 1) + '" type="checkbox"> &nbsp;&nbsp;此题是否必填</div>'
        str += '    <ul>'
        str += '        <li>'
        str += '            <input disabled class="itemCon' + (index + 1) + '" type="text" style="width:550px" value="' + (texts1) + '">'
        str += '        </li>'
        str += '    </ul>'
        str += '    <div class="itemHandle" id="handle' + (index + 1) + '">'
        str += '        <span onclick="moveUp(' + (index + 1) + ')">上移</span>'
        if (index + 1 != length)//最后一个问题没有下移功能
            str += '        <span onclick="moveDown(' + (index + 1) + ')">下移</span>'
        str += '        <span onclick="multiplex(' + (index + 1) + ')">复用</span>'
        str += '        <span onclick="delQus(' + (index + 1) + ')">删除</span>'
        str += '    </div>'
        var textQue = document.querySelector(id1)//需要下移的问题的下一个的标签
        textQue.innerHTML = str//再渲染到页面
        var newIsId = "#isMust" + (index + 1).toString()
        document.querySelector(newIsId).checked = isMust1//是否必填渲染
    }

    if (type == "单选题") {//不同的问题对应不同的代码
        var str = ""//渲染到新模板
        str += '    Q<span class="none" id="type' + (index) + '">单选题</span>'
        str += '    <span class="questionNum">' + (index) + '</span> &nbsp;&nbsp;'
        str += '    <span id="ItemTitle' + (index) + '" onclick="edit(\'Title' + (index) + '\')">' + (title) + '</span>'
        str += '    <input type="text" id="Title' + (index) + '" class="none">'
        str += '    <button id="outTitle' + (index) + '" onclick="edit(\'Title' + (index) + '\')" class="none">确定</button>'
        str += '    <button id="editQue' + (index) + '" class="editQue" onclick="addradioOp(' + (index) + ')">新增选项</button>'
        str += '    <ul id="radioUl' + (index) + '">'
        for (j = 0; j < radios.length; j++) {
            str += '        <li id="radi' + (index) + (j + 1) + '" class="radios">'
            str += '            <input disabled type="radio" name="radio1" disabled>'
            str += '            <span id="ItemRad' + (index) + (j + 1) + '" class="itemCon' + (index) + '" onclick="edit(\'Rad' + (index) + (j + 1) + '\')">' + (radios[j].innerHTML) + '</span>'
            str += '            <input type="text" id="Rad' + (index) + (j + 1) + '" class="none">'
            str += '            <button id="outRad' + (index) + (j + 1) + '" onclick="edit(\'Rad' + (index) + (j + 1) + '\')" class="none">确定</button>'
            str += '            <button class="dele' + (index) + ' dele none" onclick="delOp(\'radi' + (index) + (j + 1) + '\')">删除</button>'
            str += '        </li>'
        }
        str += '    </ul>'
        str += '    <div class="itemHandle" id="handle' + (index) + '">'
        if (index != 1)//第一个问题没有上移功能
            str += '        <span onclick="moveUp(' + (index) + ')">上移</span>'
        str += '        <span onclick="moveDown(' + (index) + ')">下移</span>'
        str += '        <span onclick="multiplex(' + (index) + ')">复用</span>'
        str += '        <span onclick="delQus(' + (index) + ')">删除</span>'
        str += '    </div>'
        var radioQue = document.querySelector(id)//需要下移的问题的标签
        radioQue.innerHTML = str//再渲染到页面
    } else if (type == "多选题") {
        var str = ""//渲染到新模板
        str += '    Q<span class="none" id="type' + (index) + '">多选题</span>'
        str += '    <span class="questionNum">' + (index) + '</span> &nbsp;&nbsp;'
        str += '    <span id="ItemTitle' + (index) + '" onclick="edit(\'Title' + (index) + '\')">' + (title) + '</span>'
        str += '    <input type="text" id="Title' + (index) + '" class="none">'
        str += '    <button id="outTitle' + (index) + '" onclick="edit(\'Title' + (index) + '\')" class="none">确定</button>'
        str += '    <button id="editQue' + (index) + '" class="editQue" onclick="addcheckOp(' + (index) + ')">新增选项</button>'
        str += '    <ul id="checkUl' + (index) + '">'
        for (j = 0; j < checks.length; j++) {
            str += '        <li id="chek' + (index) + (j + 1) + '" class="checks">'
            str += '            <input disabled type="checkbox" name="checkbox1">'
            str += '            <span id="ItemChe' + (index) + (j + 1) + '"  class="itemCon' + (index) + '" onclick="edit(\'Che' + (index) + (j + 1) + '\')">' + (checks[j].innerHTML) + '</span>'
            str += '            <input type="text" id="Che' + (index) + (j + 1) + '" class="none">'
            str += '            <button id="outChe' + (index) + (j + 1) + '" onclick="edit(\'Che' + (index) + (j + 1) + '\')" class="none">确定</button>'
            str += '            <button class="dele' + (index) + ' dele none" onclick="delOp(\'chek' + (index) + (j + 1) + '\')">删除</button>'
            str += '        </li>'
        }
        str += '    </ul>'
        str += '    <div class="itemHandle" id="handle' + (index) + '">'
        if (index != 1)//第一个问题没有上移功能
            str += '        <span onclick="moveUp(' + (index) + ')">上移</span>'
        str += '        <span onclick="moveDown(' + (index) + ')">下移</span>'
        str += '        <span onclick="multiplex(' + (index) + ')">复用</span>'
        str += '        <span onclick="delQus(' + (index) + ')">删除</span>'
        str += '    </div>'
        var checkQue = document.querySelector(id)//需要下移的问题的标签
        checkQue.innerHTML = str//再渲染到页面
    } else {
        var str = ""//渲染到新模板
        str += '    Q<span class="none" id="type' + (index) + '">文本题</span>'
        str += '    <span class="questionNum">' + (index) + '</span> &nbsp;&nbsp;'
        str += '    <span id="ItemTitle' + (index) + '" onclick="edit(\'Title' + (index) + '\')">' + (title) + '</span>'
        str += '    <div style="float: right;"><input id="isMust' + (index) + '" type="checkbox"> &nbsp;&nbsp;此题是否必填</div>'
        str += '    <ul>'
        str += '        <li>'
        str += '            <input disabled class="itemCon' + (index) + '" type="text" style="width:550px" value="' + (texts) + '">'
        str += '        </li>'
        str += '    </ul>'
        str += '    <div class="itemHandle" id="handle' + (index) + '">'
        if (index != 1)//第一个问题没有上移功能
            str += '        <span onclick="moveUp(' + (index) + ')">上移</span>'
        str += '        <span onclick="moveDown(' + (index) + ')">下移</span>'
        str += '        <span onclick="multiplex(' + (index) + ')">复用</span>'
        str += '        <span onclick="delQus(' + (index) + ')">删除</span>'
        str += '    </div>'
        var textQue = document.querySelector(id)//需要下移的问题的标签
        textQue.innerHTML = str//再渲染到页面
        var newIsId = "#isMust" + (index).toString()
        document.querySelector(newIsId).checked = isMust//是否必填渲染
    }
}
function multiplex(index) {//复用
    var length = parseInt(document.querySelectorAll(".questionNum").length)//获取问题个数
    if (length >= 10) {
        alert("问题数目不能超过十个")
        return
    } else {
        if (index == length) {//复用最后一个时,先给最后一个加上下移操作按钮
            var handleId = "#handle" + (index).toString()
            var newHand = ""
            newHand += '        <span onclick="moveUp(' + (index) + ')">上移</span>'
            newHand += '        <span onclick="moveDown(' + (index) + ')">下移</span>'
            newHand += '        <span onclick="multiplex(' + (index) + ')">复用</span>'
            newHand += '        <span onclick="delQus(' + (index) + ')">删除</span>'
            document.querySelector(handleId).innerHTML = newHand
        }
        var len = (length + 1).toString()//用于新复用问题的索引
        var newStr = ""//空壳模板
        newStr += '<div id="questionItem' + (len) + '" class="questionItem" onmouseover="show(' + (len) + ')" onmouseout="hide(' + (len) + ')">'
        newStr += '</div>'
        var content = document.querySelector("#question").innerHTML/* 先获取问题标签的所有内容 */
        document.querySelector("#question").innerHTML = content + newStr//在最后面塑造一个“空壳”
        for (i = length; i >= index; i--) {//将复用的问题后面的所有问题向后移动一位
            var id = "#questionItem" + (i + 1).toString()
            var typeId = "#type" + i.toString()
            var type = document.querySelector(typeId).innerHTML //问题类型
            var titId = "#ItemTitle" + i.toString()
            var title = document.querySelector(titId).innerHTML //问题标签
            if (type == "单选题") {//不同的问题对应不同的代码
                var radioClass = ".itemCon" + i.toString()
                var radios = document.querySelectorAll(radioClass) //先储存选项内容

                var str = ""//渲染到新模板
                str += '    Q<span class="none" id="type' + (i + 1) + '">单选题</span>'
                str += '    <span class="questionNum">' + (i + 1) + '</span> &nbsp;&nbsp;'
                str += '    <span id="ItemTitle' + (i + 1) + '" onclick="edit(\'Title' + (i + 1) + '\')">' + (title) + '</span>'
                str += '    <input type="text" id="Title' + (i + 1) + '" class="none">'
                str += '    <button id="outTitle' + (i + 1) + '" onclick="edit(\'Title' + (i + 1) + '\')" class="none">确定</button>'
                str += '    <button id="editQue' + (i + 1) + '" class="editQue" onclick="addradioOp(' + (i + 1) + ')">新增选项</button>'
                str += '    <ul id="radioUl' + (i + 1) + '">'
                for (j = 0; j < radios.length; j++) {
                    str += '        <li id="radi' + (i + 1) + (j + 1) + '" class="radios">'
                    str += '            <input disabled type="radio" name="radio1" disabled>'
                    str += '            <span id="ItemRad' + (i + 1) + (j + 1) + '" class="itemCon' + (i + 1) + '" onclick="edit(\'Rad' + (i + 1) + (j + 1) + '\')">' + (radios[j].innerHTML) + '</span>'
                    str += '            <input type="text" id="Rad' + (i + 1) + (j + 1) + '" class="none">'
                    str += '            <button id="outRad' + (i + 1) + (j + 1) + '" onclick="edit(\'Rad' + (i + 1) + (j + 1) + '\')" class="none">确定</button>'
                    str += '            <button class="dele' + (i + 1) + ' dele none" onclick="delOp(\'radi' + (i + 1) + (j + 1) + '\')">删除</button>'
                    str += '        </li>'
                }
                str += '    </ul>'
                str += '    <div class="itemHandle" id="handle' + (i + 1) + '">'
                str += '        <span onclick="moveUp(' + (i + 1) + ')">上移</span>'
                if (i != length)
                    str += '        <span onclick="moveDown(' + (i + 1) + ')">下移</span>'
                str += '        <span onclick="multiplex(' + (i + 1) + ')">复用</span>'
                str += '        <span onclick="delQus(' + (i + 1) + ')">删除</span>'
                str += '    </div>'
                var radioQue = document.querySelector(id)//需要复用的问题的下一个的标签
                radioQue.innerHTML = str//再渲染到页面
            } else if (type == "多选题") {
                var checkClass = ".itemCon" + i.toString()
                var checks = document.querySelectorAll(checkClass)//先储存选项内容

                var str = ""//渲染到新模板
                str += '    Q<span class="none" id="type' + (i + 1) + '">多选题</span>'
                str += '    <span class="questionNum">' + (i + 1) + '</span> &nbsp;&nbsp;'
                str += '    <span id="ItemTitle' + (i + 1) + '" onclick="edit(\'Title' + (i + 1) + '\')">' + (title) + '</span>'
                str += '    <input type="text" id="Title' + (i + 1) + '" class="none">'
                str += '    <button id="outTitle' + (i + 1) + '" onclick="edit(\'Title' + (i + 1) + '\')" class="none">确定</button>'
                str += '    <button id="editQue' + (i + 1) + '" class="editQue" onclick="addcheckOp(' + (i + 1) + ')">新增选项</button>'
                str += '    <ul id="checkUl' + (i + 1) + '">'
                for (j = 0; j < checks.length; j++) {
                    str += '        <li id="chek' + (i + 1) + (j + 1) + '" class="checks">'
                    str += '            <input disabled type="checkbox" name="checkbox1">'
                    str += '            <span id="ItemChe' + (i + 1) + (j + 1) + '"  class="itemCon' + (i + 1) + '" onclick="edit(\'Che' + (i + 1) + (j + 1) + '\')">' + (checks[j].innerHTML) + '</span>'
                    str += '            <input type="text" id="Che' + (i + 1) + (j + 1) + '" class="none">'
                    str += '            <button id="outChe' + (i + 1) + (j + 1) + '" onclick="edit(\'Che' + (i + 1) + (j + 1) + '\')" class="none">确定</button>'
                    str += '            <button class="dele' + (i + 1) + ' dele none" onclick="delOp(\'chek' + (i + 1) + (j + 1) + '\')">删除</button>'
                    str += '        </li>'
                }
                str += '    </ul>'
                str += '    <div class="itemHandle" id="handle' + (i + 1) + '">'
                str += '        <span onclick="moveUp(' + (i + 1) + ')">上移</span>'
                if (i != length)
                    str += '        <span onclick="moveDown(' + (i + 1) + ')">下移</span>'
                str += '        <span onclick="multiplex(' + (i + 1) + ')">复用</span>'
                str += '        <span onclick="delQus(' + (i + 1) + ')">删除</span>'
                str += '    </div>'
                var checkQue = document.querySelector(id)//需要复用的问题的下一个的标签
                checkQue.innerHTML = str//再渲染到页面
            } else {
                var textClass = ".itemCon" + i.toString()
                var isId = "#isMust" + i.toString()
                var texts = document.querySelector(textClass).value//先储存选项内容
                var isMust = document.querySelector(isId).checked
                var str = ""//渲染到新模板
                str += '    Q<span class="none" id="type' + (i + 1) + '">文本题</span>'
                str += '    <span class="questionNum">' + (i + 1) + '</span> &nbsp;&nbsp;'
                str += '    <span id="ItemTitle' + (i + 1) + '" onclick="edit(\'Title' + (i + 1) + '\')">' + (title) + '</span>'
                str += '    <input type="text" id="Title' + (i + 1) + '" class="none">'
                str += '    <button id="outTitle' + (i + 1) + '" onclick="edit(\'Title' + (i + 1) + '\')" class="none">确定</button>'
                str += '    <div style="float: right;"><input id="isMust' + (i + 1) + '" type="checkbox"> &nbsp;&nbsp;此题是否必填</div>'
                str += '    <ul>'
                str += '        <li>'
                str += '            <input disabled class="itemCon' + (i + 1) + '" type="text" style="width:550px" value="' + (texts) + '">'
                str += '        </li>'
                str += '    </ul>'
                str += '    <div class="itemHandle" id="handle' + (i + 1) + '">'
                str += '        <span onclick="moveUp(' + (i + 1) + ')">上移</span>'
                if (i != length)
                    str += '        <span onclick="moveDown(' + (i + 1) + ')">下移</span>'
                str += '        <span onclick="multiplex(' + (i + 1) + ')">复用</span>'
                str += '        <span onclick="delQus(' + (i + 1) + ')">删除</span>'
                str += '    </div>'
                var textQue = document.querySelector(id)//需要复用的问题的下一个的标签
                textQue.innerHTML = str//再渲染到页面
                var newIsId = "#isMust" + (i + 1).toString()
                document.querySelector(newIsId).checked = isMust
            }
        }
    }
}
function delQus(index) {//删除问题
    var length = parseInt(document.querySelectorAll(".questionNum").length)//获取问题个数
    var id = "#questionItem" + length.toString();
    var d = confirm("是否要删除");
    if (d) {//提醒是否需要删除
        if (index == length) { //删除的是最后一个，先删除倒数第二个的下移功能
            var handleId = "#handle" + (index - 1).toString()
            var newHand = ""
            newHand += '        <span onclick="moveUp(' + (index - 1) + ')">上移</span>'
            newHand += '        <span onclick="multiplex(' + (index - 1) + ')">复用</span>'
            newHand += '        <span onclick="delQus(' + (index - 1) + ')">删除</span>'
            document.querySelector(handleId).innerHTML = newHand
        }
        for (i = index + 1; i <= length; i++) {//所有在被删除的问题后面的问题都向前移动
            var newId = "#questionItem" + (i - 1).toString()
            var typeId = "#type" + i.toString()
            var type = document.querySelector(typeId).innerHTML //问题类型
            var titId = "#ItemTitle" + i.toString()
            var title = document.querySelector(titId).innerHTML //问题标题
            if (type == "单选题") {//不同的问题对应不同的代码
                var radioClass = ".itemCon" + i.toString()
                var radios = document.querySelectorAll(radioClass) //先储存选项内容

                var str = ""//渲染到新模板
                str += '    Q<span class="none" id="type' + (i - 1) + '">单选题</span>'
                str += '    <span class="questionNum">' + (i - 1) + '</span> &nbsp;&nbsp;'
                str += '    <span id="ItemTitle' + (i - 1) + '" onclick="edit(\'Title' + (i - 1) + '\')">' + (title) + '</span>'
                str += '    <input type="text" id="Title' + (i - 1) + '" class="none">'
                str += '    <button id="outTitle' + (i - 1) + '" onclick="edit(\'Title' + (i - 1) + '\')" class="none">确定</button>'
                str += '    <button id="editQue' + (i - 1) + '" class="editQue" onclick="addradioOp(' + (i - 1) + ')">新增选项</button>'
                str += '    <ul id="radioUl' + (i - 1) + '">'
                for (j = 0; j < radios.length; j++) {
                    str += '        <li id="radi' + (i - 1) + (j + 1) + '" class="radios">'
                    str += '            <input disabled type="radio" name="radio1" disabled>'
                    str += '            <span id="ItemRad' + (i - 1) + (j + 1) + '" class="itemCon' + (i - 1) + '" onclick="edit(\'Rad' + (i - 1) + (j + 1) + '\')">' + (radios[j].innerHTML) + '</span>'
                    str += '            <input type="text" id="Rad' + (i - 1) + (j + 1) + '" class="none">'
                    str += '            <button id="outRad' + (i - 1) + (j + 1) + '" onclick="edit(\'Rad' + (i - 1) + (j + 1) + '\')" class="none">确定</button>'
                    str += '            <button class="dele' + (i - 1) + ' dele none" onclick="delOp(\'radi' + (i - 1) + (j + 1) + '\')">删除</button>'
                    str += '        </li>'
                }
                str += '    </ul>'
                str += '    <div class="itemHandle" id="handle' + (i - 1) + '">'
                if (i - 1 != 1)
                    str += '        <span onclick="moveUp(' + (i - 1) + ')">上移</span>'
                if (i != length)
                    str += '        <span onclick="moveDown(' + (i - 1) + ')">下移</span>'
                str += '        <span onclick="multiplex(' + (i - 1) + ')">复用</span>'
                str += '        <span onclick="delQus(' + (i - 1) + ')">删除</span>'
                str += '    </div>'
                document.querySelector(newId).innerHTML = str//再渲染到页面

            } else if (type == "多选题") {
                var checkClass = ".itemCon" + i.toString()
                var checks = document.querySelectorAll(checkClass)//先储存选项内容

                var str = ""//渲染到新模板
                str += '    Q<span class="none" id="type' + (i - 1) + '">多选题</span>'
                str += '    <span class="questionNum">' + (i - 1) + '</span> &nbsp;&nbsp;'
                str += '    <span id="ItemTitle' + (i - 1) + '" onclick="edit(\'Title' + (i - 1) + '\')">' + (title) + '</span>'
                str += '    <input type="text" id="Title' + (i - 1) + '" class="none">'
                str += '    <button id="outTitle' + (i - 1) + '" onclick="edit(\'Title' + (i - 1) + '\')" class="none">确定</button>'
                str += '    <button id="editQue' + (i - 1) + '" class="editQue" onclick="addcheckOp(' + (i - 1) + ')">新增选项</button>'
                str += '    <ul id="checkUl' + (i - 1) + '">'
                for (j = 0; j < checks.length; j++) {
                    str += '        <li id="chek' + (i - 1) + (j + 1) + '" class="checks">'
                    str += '            <input disabled type="checkbox" name="checkbox1">'
                    str += '            <span id="ItemChe' + (i - 1) + (j + 1) + '"  class="itemCon' + (i - 1) + '" onclick="edit(\'Che' + (i - 1) + (j + 1) + '\')">' + (checks[j].innerHTML) + '</span>'
                    str += '            <input type="text" id="Che' + (i - 1) + (j + 1) + '" class="none">'
                    str += '            <button id="outChe' + (i - 1) + (j + 1) + '" onclick="edit(\'Che' + (i - 1) + (j + 1) + '\')" class="none">确定</button>'
                    str += '            <button class="dele' + (i - 1) + ' dele none" onclick="delOp(\'chek' + (i - 1) + (j + 1) + '\')">删除</button>'
                    str += '        </li>'
                }
                str += '    </ul>'
                str += '    <div class="itemHandle" id="handle' + (i - 1) + '">'
                if (i - 1 != 1)
                    str += '        <span onclick="moveUp(' + (i - 1) + ')">上移</span>'
                if (i != length)
                    str += '        <span onclick="moveDown(' + (i - 1) + ')">下移</span>'
                str += '        <span onclick="multiplex(' + (i - 1) + ')">复用</span>'
                str += '        <span onclick="delQus(' + (i - 1) + ')">删除</span>'
                str += '    </div>'
                document.querySelector(newId).innerHTML = str//再渲染到页面
            } else {
                var textClass = ".itemCon" + i.toString()
                var isId = "#isMust" + i.toString()
                var texts = document.querySelector(textClass).value//先储存选项内容
                var isMust = document.querySelector(isId).checked
                var str = ""//渲染到新模板
                str += '    Q<span class="none" id="type' + (i - 1) + '">文本题</span>'
                str += '    <span class="questionNum">' + (i - 1) + '</span> &nbsp;&nbsp;'
                str += '    <span id="ItemTitle' + (i - 1) + '" onclick="edit(\'Title' + (i - 1) + '\')">' + (title) + '</span>'
                str += '    <input type="text" id="Title' + (i - 1) + '" class="none">'
                str += '    <button id="outTitle' + (i - 1) + '" onclick="edit(\'Title' + (i - 1) + '\')" class="none">确定</button>'
                str += '    <div style="float: right;"><input id="isMust' + (i - 1) + '" type="checkbox"> &nbsp;&nbsp;此题是否必填</div>'
                str += '    <ul>'
                str += '        <li>'
                str += '            <input disabled class="itemCon' + (i - 1) + '" type="text" style="width:550px" value="' + (texts) + '">'
                str += '        </li>'
                str += '    </ul>'
                str += '    <div class="itemHandle" id="handle' + (i - 1) + '">'
                if (i - 1 != 1)
                    str += '        <span onclick="moveUp(' + (i - 1) + ')">上移</span>'
                if (i != length)
                    str += '        <span onclick="moveDown(' + (i - 1) + ')">下移</span>'
                str += '        <span onclick="multiplex(' + (i - 1) + ')">复用</span>'
                str += '        <span onclick="delQus(' + (i - 1) + ')">删除</span>'
                str += '    </div>'
                document.querySelector(newId).innerHTML = str
                var newIsId = "#isMust" + (i - 1).toString()
                document.querySelector(newIsId).checked = isMust//再渲染到页面
            }
        }
        document.querySelector(id).remove();//问题标签移除
        alert("删除成功")
    }
}

function saveQuestion() {//保持问卷
    time = document.querySelector("#time").value
    if (time == "") {//确保选择了问卷截止日期
        alert("请选择问卷截至日期")
        return
    }
    var tit = document.querySelector("#Itemcontent").innerHTML //获取问卷标题
    var conTent = { title: tit, state: "未发布", time: time, len: 0 };  //确定问卷状态
    var length = parseInt(document.querySelectorAll(".questionNum").length) //问卷问题个数 0<length<=10
    if (length == 0) {
        alert("请添加问题")
        return;
    }
    for (i = 1; i <= length; i++) { //循环获取问卷问题内容
        var typeId = "#type" + i.toString()
        var type = document.querySelector(typeId).innerHTML //问题类型
        var titId = "#ItemTitle" + i.toString()
        var title = document.querySelector(titId).innerHTML //问题类型
        if (type == "单选题") {
            var radi = { num: i, title: title, type: type, radio: {} }; //单选题的数据储存方式
            var radioClass = ".itemCon" + i.toString()
            var radios = document.querySelectorAll(radioClass) //选项内容
            for (j = 0; j < radios.length; j++) {
                radi.radio[j] = radios[j].innerHTML //储存选项内容
            }
            radi.radio["len"] = radios.length//选项长度
            var ra = true
            for (r = 0; r < 10; r++) {
                if (ra) {
                    var name = radi.num.toString()
                    if (!conTent[name]) { //将单选题内容存入问卷数据
                        conTent[name] = radi
                        conTent.len++//问题长度
                        ra = false
                    }
                }
            }
        } else if (type == "多选题") {
            var checkBox = { num: i, title: title, type: type, check: {}, };//多选题的数据储存方式
            var checkClass = ".itemCon" + i.toString()
            var checks = document.querySelectorAll(checkClass)//选项内容
            for (j = 0; j < checks.length; j++) {
                checkBox.check[j] = checks[j].innerHTML//储存选项内容
            }
            checkBox.check["len"] = checks.length//选项长度
            var ch = true
            for (c = 0; c < 10; c++) {
                if (ch) {
                    var name = checkBox.num.toString()
                    if (!conTent[name]) {//将多选题内容存入问卷数据
                        conTent[name] = checkBox
                        conTent.len++//问题长度
                        ch = false
                    }
                }
            }
        } else {
            var text = { num: i, title: title, type: type, textare: "" }//文本题的数据储存方式
            var textClass = ".itemCon" + i.toString()
            var isId = "#isMust" + i.toString()
            var texts = document.querySelector(textClass).value//选项内容
            text.textare = texts//储存选项内容
            if (document.querySelector(isId).checked)//存储文本题是否必填
                text["isMust"] = true
            else
                text["isMust"] = false
            var te = true
            for (t = 0; t < 10; t++) {
                if (te) {
                    var name = text.num.toString()
                    if (!conTent[name]) {//将文本题内容存入问卷数据
                        conTent[name] = text
                        conTent.len++//问题长度
                        te = false
                    }
                }
            }
        }
    }
    if (!index) {
        if (localStorage.getItem("number") == null) {
            var number = { num: 1 }//用做问卷索引
            localStorage.setItem("number", JSON.stringify(number))//存入问卷索引
        } else
            var number = JSON.parse(localStorage.getItem("number"))
        localStorage.setItem(number.num, JSON.stringify(conTent))//将问卷数据存入本地浏览器
        number.num++
        localStorage.setItem("number", JSON.stringify(number))//存入问卷索引
    } else {
        localStorage.removeItem(index)//将问卷数据存入本地浏览器
        localStorage.setItem(index, JSON.stringify(conTent))//将问卷数据存入本地浏览器
    }
    location.assign("/index.html")//保持完数据后跳转到问卷列表
}
function relQuestion() {
    time = document.querySelector("#time").value
    if (time == "") {
        alert("请选择问卷截至日期")
        return
    } else if (confirm("是否要发布\n此问卷的截止日期为：" + time)) {
        var tit = document.querySelector("#Itemcontent").innerHTML //获取问卷标题
        var conTent = { title: tit, state: "发布中", time: time, len: 0 };  //确定问卷状态
        var length = parseInt(document.querySelectorAll(".questionNum").length) //问卷问题个数 0<length<=10
        if (length === 0) {
            alert("请添加问题")
            return;
        }
        for (i = 1; i <= length; i++) {//循环获取问卷问题内容
            var typeId = "#type" + i.toString()
            var type = document.querySelector(typeId).innerHTML //问题类型
            var titId = "#ItemTitle" + i.toString()
            var title = document.querySelector(titId).innerHTML//问题类型
            if (type == "单选题") {
                var radi = { num: i, title: title, type: type, radio: {}, data: {} }; //单选题的数据储存方式
                var radioClass = ".itemCon" + i.toString()
                var radios = document.querySelectorAll(radioClass) //选项内容
                for (j = 0; j < radios.length; j++) {
                    radi.radio[j] = radios[j].innerHTML //储存选项内容
                    radi.data[j] = 0 //储存选项内容
                }
                radi.radio["len"] = radios.length//选项长度
                radi.data["len"] = 0
                var ra = true
                for (r = 0; r < 10; r++) {
                    if (ra) {
                        var name = radi.num.toString()
                        if (!conTent[name]) { //将单选题内容存入问卷数据
                            conTent[name] = radi
                            conTent.len++//问题长度
                            ra = false
                        }
                    }
                }
            } else if (type == "多选题") {
                var checkBox = { num: i, title: title, type: type, check: {}, data: {} };//多选题的数据储存方式
                var checkClass = ".itemCon" + i.toString()
                var checks = document.querySelectorAll(checkClass)//选项内容
                for (j = 0; j < checks.length; j++) {
                    checkBox.check[j] = checks[j].innerHTML//储存选项内容
                    checkBox.data[j] = 0 //储存选项内容
                }
                checkBox.check["len"] = checks.length//选项长度
                checkBox.data["len"] = 0
                var ch = true
                for (c = 0; c < 10; c++) {
                    if (ch) {
                        var name = checkBox.num.toString()
                        if (!conTent[name]) {//将多选题内容存入问卷数据
                            conTent[name] = checkBox
                            conTent.len++//问题长度
                            ch = false
                        }
                    }
                }
            } else {
                var text = { num: i, title: title, type: type, textare: "", data: { effect: 0, len: 0 } }//文本题的数据储存方式
                var textClass = ".itemCon" + i.toString()
                var isId = "#isMust" + i.toString()
                var texts = document.querySelector(textClass).value//选项内容
                text.textare = texts//储存选项内容
                if (document.querySelector(isId).checked)//存储文本题是否必填
                    text["isMust"] = true
                else
                    text["isMust"] = false
                var te = true
                for (t = 0; t < 10; t++) {
                    if (te) {
                        var name = text.num.toString()
                        if (!conTent[name]) {//将文本题内容存入问卷数据
                            conTent[name] = text
                            conTent.len++//问题长度
                            te = false
                        }
                    }
                }
            }
        }
        if (!index) {
            if (localStorage.getItem("number") == null) {
                var number = { num: 1 }//用做问卷索引
                localStorage.setItem("number", JSON.stringify(number))//存入问卷索引
            } else
                var number = JSON.parse(localStorage.getItem("number"))
            console.log(number)
            localStorage.setItem(number.num, JSON.stringify(conTent))//将问卷数据存入本地浏览器
            number.num++
            localStorage.setItem("number", JSON.stringify(number))//存入问卷索引
        } else {
            localStorage.removeItem(index)//将问卷数据存入本地浏览器
            localStorage.setItem(index, JSON.stringify(conTent))//将问卷数据存入本地浏览器
        }
        location.assign("/index.html")//保持完数据后跳转到问卷列表
    } else
        return;
}